using System;
using GammaJul.ReSharper.GammaXaml.Highlightings.Xaml;
using JetBrains.Annotations;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Daemon;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Xaml.Impl.Tree;

[assembly: RegisterConfigurableSeverity(
	MeaninglessAttachedSetterWhenAttributePresentHighlighting.SeverityId,
	null,
	HighlightingGroupIds.CodeRedundancy,
	MeaninglessAttachedSetterWhenAttributePresentHighlighting.Description,
	MeaninglessAttachedSetterWhenAttributePresentHighlighting.Description,
	Severity.SUGGESTION,
	false)]

namespace GammaJul.ReSharper.GammaXaml.Highlightings.Xaml {

	/// <summary>
	/// An highlighting that indicates that an attached setter has no meaning unless it's on some type where a specific attribute is present.
	/// </summary>
	[ConfigurableSeverityHighlighting(SeverityId, XamlProjectFileType.Name, AttributeId = HighlightingAttributeIds.DEADCODE_ATTRIBUTE, OverlapResolve = OverlapResolveKind.DEADCODE)]
	public class MeaninglessAttachedSetterWhenAttributePresentHighlighting : MeaninglessAttachedSetterHighlightingBase {
		internal const string SeverityId = "Xaml.MeaninglessAttachedSetterWhenAttributePresent";
		internal const string Description = "An attached property setter only have a meaning on types where a specific attribute is present.";

		private readonly IClrTypeName _attributePresentClrName;

		[NotNull]
		public IClrTypeName AttributePresentClrName {
			get { return _attributePresentClrName; }
		}

		protected override string GetToolTipEnd() {
			return "types having a '" + _attributePresentClrName.FullName + "' attribute";
		}

		public MeaninglessAttachedSetterWhenAttributePresentHighlighting([NotNull] IPropertySetter propertySetter, [NotNull] IMethod attachedSetter, [NotNull] IClrTypeName attributePresentClrName)
			: base(propertySetter, attachedSetter) {
			if (attributePresentClrName == null)
				throw new ArgumentNullException("attributePresentClrName");

			_attributePresentClrName = attributePresentClrName;
		}
	}

}